clear  
cd "${path}"

use "${path}/Data/PSID_individual_raw_data.dta" , replace

* Keep only sons
gen son_id = ER30001*1000+ER30002
sort son_id
cd "${path}"
merge 1:1 son_id using Data/ig_links_nocds_ad.dta
keep if _merge==3
drop _merge

* Rename the household id variable
ren ER30001 intnr68
ren ER30020 intnr69
ren ER30043 intnr70
ren ER30067 intnr71
ren ER30091 intnr72
ren ER30117 intnr73
ren ER30138 intnr74
ren ER30160 intnr75
ren ER30188 intnr76
ren ER30217 intnr77
ren ER30246 intnr78
ren ER30283 intnr79
ren ER30313 intnr80
ren ER30343 intnr81
ren ER30373 intnr82
ren ER30399 intnr83
ren ER30429 intnr84
ren ER30463 intnr85
ren ER30498 intnr86
ren ER30535 intnr87
ren ER30570 intnr88
ren ER30606 intnr89
ren ER30642 intnr90
ren ER30689 intnr91
ren ER30733 intnr92
ren ER30806 intnr93
ren ER33101 intnr94
ren ER33201 intnr95
ren ER33301 intnr96
ren ER33401 intnr97
ren ER33501 intnr99
ren ER33601 intnr101
ren ER33701 intnr103
ren ER33801 intnr105
ren ER33901 intnr107
ren ER34001 intnr109
ren ER34101 intnr111
ren ER34201 intnr113
ren ER34301 intnr115
ren ER34501 intnr117

	* Merge family/household variables
	set more off, permanently
	cd "${rawdata}/PSID fam"
	forval t=68/93 {
	local y=1900+`t'
	cd fam`y'
	merge m:1 intnr`t' using fam`y', keep(match master) nogen
	local s = `t'-1
	rename intnr`t' intnr`s'
	cd ..
	}
	forval t=94/97 {
	local y=1900+`t'
	cd fam`y'er
	merge m:1 intnr`t' using fam`y', keep(match master) nogen
	local s = `t'-1
	rename intnr`t' intnr`s'
	cd ..
	}
	forval t=99(2)117 {
	local y=1900+`t'
	cd fam`y'er
	merge m:1 intnr`t' using fam`y', keep(match master) nogen
	local s = `t'-1
	rename intnr`t' intnr`s'
	cd ..
	}

* Rename sex variable

rename ER32000 SEXSON

* Rename the sequence number for sons
* Sequence number corresponds to previous year (note there is no seq. no. for 1968 -> 1967)

ren ER30021 SEQNOSONS68
ren ER30044 SEQNOSONS69
ren ER30068 SEQNOSONS70
ren ER30092 SEQNOSONS71
ren ER30118 SEQNOSONS72
ren ER30139 SEQNOSONS73
ren ER30161 SEQNOSONS74
ren ER30189 SEQNOSONS75
ren ER30218 SEQNOSONS76
ren ER30247 SEQNOSONS77
ren ER30284 SEQNOSONS78
ren ER30314 SEQNOSONS79
ren ER30344 SEQNOSONS80
ren ER30374 SEQNOSONS81
ren ER30400 SEQNOSONS82
ren ER30430 SEQNOSONS83
ren ER30464 SEQNOSONS84
ren ER30499 SEQNOSONS85
ren ER30536 SEQNOSONS86
ren ER30571 SEQNOSONS87
ren ER30607 SEQNOSONS88
ren ER30643 SEQNOSONS89
ren ER30690 SEQNOSONS90
ren ER30734 SEQNOSONS91
ren ER30807 SEQNOSONS92
ren ER33102 SEQNOSONS93
ren ER33202 SEQNOSONS94
ren ER33302 SEQNOSONS95
ren ER33402 SEQNOSONS96
ren ER33502 SEQNOSONS98
ren ER33602 SEQNOSONS100
ren ER33702 SEQNOSONS102
ren ER33802 SEQNOSONS104
ren ER33902 SEQNOSONS106
ren ER34002 SEQNOSONS108
ren ER34102 SEQNOSONS110
ren ER34202 SEQNOSONS112
ren ER34302 SEQNOSONS114
ren ER34502 SEQNOSONS116

* Relation to head variable

ren ER30003 RELSON67
ren ER30022 RELSON68
ren ER30045 RELSON69
ren ER30069 RELSON70
ren ER30093 RELSON71
ren ER30119 RELSON72
ren ER30140 RELSON73
ren ER30162 RELSON74
ren ER30190 RELSON75
ren ER30219 RELSON76
ren ER30248 RELSON77
ren ER30285 RELSON78
ren ER30315 RELSON79
ren ER30345 RELSON80
ren ER30375 RELSON81
ren ER30401 RELSON82
ren ER30431 RELSON83
ren ER30465 RELSON84
ren ER30500 RELSON85
ren ER30537 RELSON86
ren ER30572 RELSON87
ren ER30608 RELSON88
ren ER30644 RELSON89
ren ER30691 RELSON90
ren ER30735 RELSON91
ren ER30808 RELSON92
ren ER33103 RELSON93
ren ER33203 RELSON94
ren ER33303 RELSON95
ren ER33403 RELSON96
ren ER33503 RELSON98
ren ER33603 RELSON100
ren ER33703 RELSON102
ren ER33803 RELSON104
ren ER33903 RELSON106
ren ER34003 RELSON108
ren ER34103 RELSON110
ren ER34203 RELSON112
ren ER34303 RELSON114
ren ER34503 RELSON116

* Total FAMILY MONEY INCOME 

ren V81 FMONEYSON67 			
ren V529 FMONEYSON68			
ren V1514 FMONEYSON69		
ren V2226 FMONEYSON70		
ren V2852 FMONEYSON71		
ren V3256 FMONEYSON72		
ren V3676 FMONEYSON73		
ren V4154 FMONEYSON74		
ren V5029 FMONEYSON75		
ren V5626 FMONEYSON76		
ren V6173 FMONEYSON77		
ren V6766 FMONEYSON78		
ren V7412 FMONEYSON79		
ren V8065 FMONEYSON80		
ren V8689 FMONEYSON81		
ren V9375 FMONEYSON82		
ren V11022 FMONEYSON83		
ren V12371 FMONEYSON84		
ren V13623 FMONEYSON85		
ren V14670 FMONEYSON86		
ren V16144 FMONEYSON87		
ren V17533 FMONEYSON88		
ren V18875 FMONEYSON89		
ren V20175 FMONEYSON90		
ren V21481 FMONEYSON91		
ren V23322 FMONEYSON92		
ren ER4153 FMONEYSON93		
ren ER6993 FMONEYSON94		
ren ER9244 FMONEYSON95		
ren ER12079 FMONEYSON96	
ren ER16462 FMONEYSON98	
ren ER20456 FMONEYSON100		
ren ER24099 FMONEYSON102	
ren ER28037 FMONEYSON104	
ren ER41027 FMONEYSON106	
ren ER46935 FMONEYSON108	
ren ER52343 FMONEYSON110		
ren ER58152 FMONEYSON112		
ren ER65349 FMONEYSON114		
ren ER71426 FMONEYSON116		

* Rename income imputation variables 
ren V85   FMSONACC67  // ACCURACY LBR INC HOUSEHOLD HEAD (2==major imputation)
ren V515  FMSONACC68
ren V1197 FMSONACC69
ren V1898 FMSONACC70
ren V2499 FMSONACC71
ren V3052 FMSONACC72
ren V3464 FMSONACC73
ren V3864 FMSONACC74
	
ren V86   FMSONWACC67 // ACCURACY LBR INC WIFE (2==major imputation)
ren V517  FMSONWACC68
ren V1199 FMSONWACC69
ren V1900 FMSONWACC70
ren V2501 FMSONWACC71
ren V3054 FMSONWACC72
ren V3466 FMSONWACC73
ren V3866 FMSONWACC74

ren V5783 FMSONWAGEACC77  // (2==major imputation)
ren V6392 FMSONWAGEACC78	
ren V6982 FMSONWAGEACC79
ren V7574 FMSONWAGEACC80	
ren V8266 FMSONWAGEACC81	
ren V8874 FMSONWAGEACC82	
ren V10257 FMSONWAGEACC83	
ren V11398 FMSONWAGEACC84	
ren V12797 FMSONWAGEACC85	
ren V13899 FMSONWAGEACC86	
ren V14914 FMSONWAGEACC87	
ren V16414 FMSONWAGEACC88	
ren V17830 FMSONWAGEACC89	
ren V19130 FMSONWAGEACC90
ren V20430 FMSONWAGEACC91
	
* Rename reported age variables for sons (heads)

ren V117 AGESONHEAD68	
ren V1008 AGESONHEAD69 
ren V1239 AGESONHEAD70	
ren V1942 AGESONHEAD71 
ren V2542 AGESONHEAD72	
ren V3095 AGESONHEAD73	
ren V3508 AGESONHEAD74	
ren V3921 AGESONHEAD75	
ren V4436 AGESONHEAD76	
ren V5350 AGESONHEAD77	
ren V5850 AGESONHEAD78	
ren V6462 AGESONHEAD79	
ren V7067 AGESONHEAD80	
ren V7658 AGESONHEAD81	
ren V8352 AGESONHEAD82	
ren V8961 AGESONHEAD83	
ren V10419 AGESONHEAD84	
ren V11606 AGESONHEAD85	
ren V13011 AGESONHEAD86	
ren V14114 AGESONHEAD87	
ren V15130 AGESONHEAD88	
ren V16631 AGESONHEAD89	
ren V18049 AGESONHEAD90	
ren V19349 AGESONHEAD91	
ren V20651 AGESONHEAD92	
ren V22406 AGESONHEAD93	
ren ER2007 AGESONHEAD94	
ren ER5006 AGESONHEAD95	
ren ER7006 AGESONHEAD96	
ren ER10009 AGESONHEAD97	
ren ER13010 AGESONHEAD99	
ren ER17013 AGESONHEAD101	
ren ER21017 AGESONHEAD103	
ren ER25017 AGESONHEAD105	
ren ER36017 AGESONHEAD107	
ren ER42017 AGESONHEAD109	
ren ER47317 AGESONHEAD111	
ren ER53017 AGESONHEAD113	
ren ER60017 AGESONHEAD115	
ren ER66017 AGESONHEAD117	


* Rename reported age variables for sons ("wives")

ren V118 AGESONWIFE68		
ren V1011 AGESONWIFE69  
ren V1241 AGESONWIFE70		
ren V1944 AGESONWIFE71		
ren V2544 AGESONWIFE72	
ren V3097 AGESONWIFE73	
ren V3510 AGESONWIFE74	
ren V3923 AGESONWIFE75	
ren V4438 AGESONWIFE76	
ren V5352 AGESONWIFE77	
ren V5852 AGESONWIFE78	
ren V6464 AGESONWIFE79	
ren V7069 AGESONWIFE80	
ren V7660 AGESONWIFE81	
ren V8354 AGESONWIFE82	
ren V8963 AGESONWIFE83	
ren V10421 AGESONWIFE84	
ren V11608 AGESONWIFE85	
ren V13013 AGESONWIFE86	
ren V14116 AGESONWIFE87	
ren V15132 AGESONWIFE88	
ren V16633 AGESONWIFE89	
ren V18051 AGESONWIFE90	
ren V19351 AGESONWIFE91	
ren V20653 AGESONWIFE92	
ren V22408 AGESONWIFE93	
ren ER2009 AGESONWIFE94	
ren ER5008 AGESONWIFE95	
ren ER7008 AGESONWIFE96	
ren ER10011 AGESONWIFE97	
ren ER13012 AGESONWIFE99	
ren ER17015 AGESONWIFE101	
ren ER21019 AGESONWIFE103	
ren ER25019 AGESONWIFE105	
ren ER36019 AGESONWIFE107	
ren ER42019 AGESONWIFE109	
ren ER47319 AGESONWIFE111	
ren ER53019 AGESONWIFE113	
ren ER60019 AGESONWIFE115	
ren ER66019 AGESONWIFE117	

* Rename education variable

ren ER30010 EDUSON67
ren ER30052 EDUSON69
ren ER30076 EDUSON70
ren ER30100 EDUSON71
ren ER30126 EDUSON72
ren ER30147 EDUSON73
ren ER30169 EDUSON74
ren ER30197 EDUSON75
ren ER30226 EDUSON76
ren ER30255 EDUSON77
ren ER30296 EDUSON78
ren ER30326 EDUSON79
ren ER30356 EDUSON80
ren ER30384 EDUSON81
ren ER30413 EDUSON82
ren ER30443 EDUSON83
ren ER30478 EDUSON84
ren ER30513 EDUSON85
ren ER30549 EDUSON86
ren ER30584 EDUSON87
ren ER30620 EDUSON88
ren ER30657 EDUSON89
ren ER30703 EDUSON90
ren ER30748 EDUSON91
ren ER30820 EDUSON92
ren ER33115 EDUSON93
ren ER33215 EDUSON94
ren ER33315 EDUSON95
ren ER33415 EDUSON96
ren ER33516 EDUSON98
ren ER33616 EDUSON100
ren ER33716 EDUSON102
ren ER33817 EDUSON104
ren ER33917 EDUSON106
ren ER34020 EDUSON108
ren ER34119 EDUSON110
ren ER34230 EDUSON112
ren ER34349 EDUSON114
ren ER34548 EDUSON116

* Rename race of head variable

ren V181 RACEH67		
ren V801 RACEH68	
ren V1490 RACEH69	
ren V2202 RACEH70	
ren V2828 RACEH71	
ren V3300 RACEH72	
ren V3720 RACEH73	
ren V4204 RACEH74	
ren V5096 RACEH75	
ren V5662 RACEH76	
ren V6209 RACEH77	
ren V6802 RACEH78	
ren V7447 RACEH79	
ren V8099 RACEH80	
ren V8723 RACEH81	
ren V9408 RACEH82	
ren V11055 RACEH83	
ren V11938 RACEH84	
ren V13565 RACEH85	
ren V14612 RACEH86	
ren V16086 RACEH87	
ren V17483 RACEH88	
ren V18814 RACEH89	
ren V20114 RACEH90	
ren V21420 RACEH91	
ren V23276 RACEH92	
ren ER3944 RACEH93	
ren ER6814 RACEH94	
ren ER9060 RACEH95	
ren ER11848 RACEH96	
ren ER15928 RACEH98	
ren ER19989 RACEH100	
ren ER23426 RACEH102	
ren ER27393 RACEH104	
ren ER40565 RACEH106	
ren ER46543 RACEH108	
ren ER51904 RACEH110	
ren ER57659 RACEH112	
ren ER64810 RACEH114	
ren ER70882 RACEH116	

* Rename race of "wife" variable

ren V12293 RACEW84	
ren V13500 RACEW85	
ren V14547 RACEW86	
ren V16021 RACEW87	
ren V17418 RACEW88	
ren V18749 RACEW89	
ren V20049 RACEW90	
ren V21355 RACEW91	
ren V23212 RACEW92	
ren ER3883 RACEW93	
ren ER6753 RACEW94	
ren ER8999 RACEW95	
ren ER11760 RACEW96	
ren ER15836 RACEW98	
ren ER19897 RACEW100	
ren ER23334 RACEW102	
ren ER27297 RACEW104	
ren ER40472 RACEW106	
ren ER46449 RACEW108	
ren ER51810 RACEW110	
ren ER57549 RACEW112	
ren ER64671 RACEW114	
ren ER70744 RACEW116	

* Rename family weight variable

ren V439 FAMWEIGHTSON67		
ren V1014 FAMWEIGHTSON68		
ren V1609 FAMWEIGHTSON69		
ren V2321 FAMWEIGHTSON70		
ren V2968 FAMWEIGHTSON71		
ren V3301 FAMWEIGHTSON72		
ren V3721 FAMWEIGHTSON73		
ren V4224 FAMWEIGHTSON74		
ren V5099 FAMWEIGHTSON75		
ren V5665 FAMWEIGHTSON76		
ren V6212 FAMWEIGHTSON77		
ren V6805 FAMWEIGHTSON78		
ren V7451 FAMWEIGHTSON79		
ren V8103 FAMWEIGHTSON80		
ren V8727 FAMWEIGHTSON81		
ren V9433 FAMWEIGHTSON82		
ren V11079 FAMWEIGHTSON83	
ren V12446 FAMWEIGHTSON84	
ren V13687 FAMWEIGHTSON85	
ren V14737 FAMWEIGHTSON86	
ren V16208 FAMWEIGHTSON87	
ren V17612 FAMWEIGHTSON88	
ren V18943 FAMWEIGHTSON89	
ren V20243 FAMWEIGHTSON90	
ren V21547 FAMWEIGHTSON91	
ren V23361 FAMWEIGHTSON92	
ren ER4160 FAMWEIGHTSON93	
ren ER7000 FAMWEIGHTSON94	
ren ER9251 FAMWEIGHTSON95	
ren ER12084 FAMWEIGHTSON96	
ren ER16518 FAMWEIGHTSON98	
ren ER20394 FAMWEIGHTSON100	
ren ER24179 FAMWEIGHTSON102	
ren ER28078 FAMWEIGHTSON104	
ren ER41069 FAMWEIGHTSON106 	
ren ER47012 FAMWEIGHTSON108 	
ren ER52436 FAMWEIGHTSON110	
ren ER58257 FAMWEIGHTSON112	
ren ER65492 FAMWEIGHTSON114	
ren ER71570 FAMWEIGHTSON116	

* Family members

* Rename # family size variable

ren V115 FUMEMBERSSON68		
ren V549 FUMEMBERSSON69		
ren V1238 FUMEMBERSSON70		
ren V1941 FUMEMBERSSON71		
ren V2541 FUMEMBERSSON72		
ren V3094 FUMEMBERSSON73		
ren V3507 FUMEMBERSSON74		
ren V3920 FUMEMBERSSON75		
ren V4435 FUMEMBERSSON76		
ren V5349 FUMEMBERSSON77		
ren V5849 FUMEMBERSSON78		
ren V6461 FUMEMBERSSON79		
ren V7066 FUMEMBERSSON80		
ren V7657 FUMEMBERSSON81		
ren V8351 FUMEMBERSSON82		
ren V8960 FUMEMBERSSON83		
ren V10418 FUMEMBERSSON84	
ren V11605 FUMEMBERSSON85	
ren V13010 FUMEMBERSSON86	
ren V14113 FUMEMBERSSON87	
ren V15129 FUMEMBERSSON88	
ren V16630 FUMEMBERSSON89	
ren V18048 FUMEMBERSSON90	
ren V19348 FUMEMBERSSON91	
ren V20650 FUMEMBERSSON92	
ren V22405 FUMEMBERSSON93	
ren ER2006 FUMEMBERSSON94	
ren ER5005 FUMEMBERSSON95	
ren ER7005 FUMEMBERSSON96	
ren ER10008 FUMEMBERSSON97	
ren ER13009 FUMEMBERSSON99	
ren ER17012 FUMEMBERSSON01	
ren ER21016 FUMEMBERSSON03	
ren ER25016 FUMEMBERSSON05	
ren ER36016 FUMEMBERSSON07	
ren ER42016 FUMEMBERSSON09	
ren ER47316 FUMEMBERSSON11	
ren ER53016 FUMEMBERSSON13	
ren ER60016 FUMEMBERSSON15	
ren ER66016 FUMEMBERSSON17	

* # of kids in family

rename V398 KIDSNUMBERSON68		
rename V550 KIDSNUMBERSON69		
rename V1242 KIDSNUMBERSON70	
rename V1945 KIDSNUMBERSON71	
rename V2545 KIDSNUMBERSON72	
rename V3098 KIDSNUMBERSON73	
rename V3511 KIDSNUMBERSON74	
rename V3924 KIDSNUMBERSON75	
rename V4439 KIDSNUMBERSON76	
rename V5353 KIDSNUMBERSON77	
rename V5853 KIDSNUMBERSON78	
rename V6465 KIDSNUMBERSON79	
rename V7070 KIDSNUMBERSON80	
rename V7661 KIDSNUMBERSON81	
rename V8355 KIDSNUMBERSON82	
rename V8964 KIDSNUMBERSON83		
rename V10422 KIDSNUMBERSON84	
rename V11609 KIDSNUMBERSON85	
rename V13014 KIDSNUMBERSON86	
rename V14117 KIDSNUMBERSON87	
rename V15133 KIDSNUMBERSON88	
rename V16634 KIDSNUMBERSON89	
rename V18052 KIDSNUMBERSON90	
rename V19352 KIDSNUMBERSON91	
rename V20654 KIDSNUMBERSON92	
rename V22409 KIDSNUMBERSON93	
rename ER2010 KIDSNUMBERSON94	
rename ER5009 KIDSNUMBERSON95	
rename ER7009 KIDSNUMBERSON96	
rename ER10012 KIDSNUMBERSON97	
rename ER13013 KIDSNUMBERSON99	
rename ER17016 KIDSNUMBERSON01	
rename ER21020 KIDSNUMBERSON03	
rename ER25020 KIDSNUMBERSON05	
rename ER36020 KIDSNUMBERSON07	
rename ER42020 KIDSNUMBERSON09	
rename ER47320 KIDSNUMBERSON11	
rename ER53020 KIDSNUMBERSON13	
rename ER60021 KIDSNUMBERSON15	
rename ER66021 KIDSNUMBERSON17	

* Ind. weight son

rename ER30019  INDWTSON67	
rename ER30042  INDWTSON68
rename ER30066  INDWTSON69
rename ER30090  INDWTSON70
rename ER30116  INDWTSON71
rename ER30137  INDWTSON72
rename ER30159  INDWTSON73
rename ER30187  INDWTSON74
rename ER30216 INDWTSON75
rename ER30245 INDWTSON76
rename ER30282 INDWTSON77
rename ER30312 INDWTSON78
rename ER30342 INDWTSON79
rename ER30372 INDWTSON80
rename ER30398 INDWTSON81
rename ER30428 INDWTSON82
rename ER30462 INDWTSON83
rename ER30497 INDWTSON84
rename ER30534 INDWTSON85
rename ER30569 INDWTSON86
rename ER30605 INDWTSON87
rename ER30641 INDWTSON88
rename ER30686 INDWTSON89
rename ER30730 INDWTSON90
rename ER30803 INDWTSON91
rename ER30864 INDWTSON92
rename ER33119 INDWTSON93
rename ER33275 INDWTSON94
rename ER33318 INDWTSON95
rename ER33430 INDWTSON96
rename ER33546 INDWTSON98
rename ER33637 INDWTSON100
rename ER33740 INDWTSON102
rename ER33848 INDWTSON104
rename ER33950 INDWTSON106
rename ER34045 INDWTSON108
rename ER34154 INDWTSON110
rename ER34268 INDWTSON112
rename ER34413 INDWTSON114
rename ER34650 INDWTSON116


* Rename variables, to match them with previous years

ren KIDSNUMBERSON68 KIDSNUMBERSON67
ren KIDSNUMBERSON69 KIDSNUMBERSON68
ren KIDSNUMBERSON70 KIDSNUMBERSON69
ren KIDSNUMBERSON71 KIDSNUMBERSON70
ren KIDSNUMBERSON72 KIDSNUMBERSON71
ren KIDSNUMBERSON73 KIDSNUMBERSON72
ren KIDSNUMBERSON74 KIDSNUMBERSON73
ren KIDSNUMBERSON75 KIDSNUMBERSON74
ren KIDSNUMBERSON76 KIDSNUMBERSON75
ren KIDSNUMBERSON77 KIDSNUMBERSON76
ren KIDSNUMBERSON78 KIDSNUMBERSON77
ren KIDSNUMBERSON79 KIDSNUMBERSON78
ren KIDSNUMBERSON80 KIDSNUMBERSON79
ren KIDSNUMBERSON81 KIDSNUMBERSON80
ren KIDSNUMBERSON82 KIDSNUMBERSON81
ren KIDSNUMBERSON83 KIDSNUMBERSON82
ren KIDSNUMBERSON84 KIDSNUMBERSON83
ren KIDSNUMBERSON85 KIDSNUMBERSON84
ren KIDSNUMBERSON86 KIDSNUMBERSON85
ren KIDSNUMBERSON87 KIDSNUMBERSON86
ren KIDSNUMBERSON88 KIDSNUMBERSON87
ren KIDSNUMBERSON89 KIDSNUMBERSON88
ren KIDSNUMBERSON90 KIDSNUMBERSON89
ren KIDSNUMBERSON91 KIDSNUMBERSON90
ren KIDSNUMBERSON92 KIDSNUMBERSON91
ren KIDSNUMBERSON93 KIDSNUMBERSON92
ren KIDSNUMBERSON94 KIDSNUMBERSON93
ren KIDSNUMBERSON95 KIDSNUMBERSON94
ren KIDSNUMBERSON96 KIDSNUMBERSON95
ren KIDSNUMBERSON97 KIDSNUMBERSON96
ren KIDSNUMBERSON99 KIDSNUMBERSON98
ren KIDSNUMBERSON01 KIDSNUMBERSON100
ren KIDSNUMBERSON03 KIDSNUMBERSON102
ren KIDSNUMBERSON05 KIDSNUMBERSON104
ren KIDSNUMBERSON07 KIDSNUMBERSON106
ren KIDSNUMBERSON09 KIDSNUMBERSON108
ren KIDSNUMBERSON11 KIDSNUMBERSON110
ren KIDSNUMBERSON13 KIDSNUMBERSON112
ren KIDSNUMBERSON15 KIDSNUMBERSON114
ren KIDSNUMBERSON17 KIDSNUMBERSON116

ren FUMEMBERSSON68 FUMEMBERSSON67
ren FUMEMBERSSON69 FUMEMBERSSON68
ren FUMEMBERSSON70 FUMEMBERSSON69
ren FUMEMBERSSON71 FUMEMBERSSON70
ren FUMEMBERSSON72 FUMEMBERSSON71
ren FUMEMBERSSON73 FUMEMBERSSON72
ren FUMEMBERSSON74 FUMEMBERSSON73
ren FUMEMBERSSON75 FUMEMBERSSON74
ren FUMEMBERSSON76 FUMEMBERSSON75
ren FUMEMBERSSON77 FUMEMBERSSON76
ren FUMEMBERSSON78 FUMEMBERSSON77
ren FUMEMBERSSON79 FUMEMBERSSON78
ren FUMEMBERSSON80 FUMEMBERSSON79
ren FUMEMBERSSON81 FUMEMBERSSON80
ren FUMEMBERSSON82 FUMEMBERSSON81
ren FUMEMBERSSON83 FUMEMBERSSON82
ren FUMEMBERSSON84 FUMEMBERSSON83
ren FUMEMBERSSON85 FUMEMBERSSON84
ren FUMEMBERSSON86 FUMEMBERSSON85
ren FUMEMBERSSON87 FUMEMBERSSON86
ren FUMEMBERSSON88 FUMEMBERSSON87
ren FUMEMBERSSON89 FUMEMBERSSON88
ren FUMEMBERSSON90 FUMEMBERSSON89
ren FUMEMBERSSON91 FUMEMBERSSON90
ren FUMEMBERSSON92 FUMEMBERSSON91
ren FUMEMBERSSON93 FUMEMBERSSON92
ren FUMEMBERSSON94 FUMEMBERSSON93
ren FUMEMBERSSON95 FUMEMBERSSON94
ren FUMEMBERSSON96 FUMEMBERSSON95
ren FUMEMBERSSON97 FUMEMBERSSON96
ren FUMEMBERSSON99 FUMEMBERSSON98
ren FUMEMBERSSON01 FUMEMBERSSON100
ren FUMEMBERSSON03 FUMEMBERSSON102
ren FUMEMBERSSON05 FUMEMBERSSON104
ren FUMEMBERSSON07 FUMEMBERSSON106
ren FUMEMBERSSON09 FUMEMBERSSON108
ren FUMEMBERSSON11 FUMEMBERSSON110
ren FUMEMBERSSON13 FUMEMBERSSON112	
ren FUMEMBERSSON15 FUMEMBERSSON114
ren FUMEMBERSSON17 FUMEMBERSSON116

ren AGESONHEAD68 AGESONHEAD67
ren AGESONHEAD69 AGESONHEAD68
ren AGESONHEAD70 AGESONHEAD69
ren AGESONHEAD71 AGESONHEAD70
ren AGESONHEAD72 AGESONHEAD71
ren AGESONHEAD73 AGESONHEAD72
ren AGESONHEAD74 AGESONHEAD73
ren AGESONHEAD75 AGESONHEAD74
ren AGESONHEAD76 AGESONHEAD75
ren AGESONHEAD77 AGESONHEAD76
ren AGESONHEAD78 AGESONHEAD77
ren AGESONHEAD79 AGESONHEAD78
ren AGESONHEAD80 AGESONHEAD79
ren AGESONHEAD81 AGESONHEAD80
ren AGESONHEAD82 AGESONHEAD81
ren AGESONHEAD83 AGESONHEAD82
ren AGESONHEAD84 AGESONHEAD83
ren AGESONHEAD85 AGESONHEAD84
ren AGESONHEAD86 AGESONHEAD85
ren AGESONHEAD87 AGESONHEAD86
ren AGESONHEAD88 AGESONHEAD87
ren AGESONHEAD89 AGESONHEAD88
ren AGESONHEAD90 AGESONHEAD89
ren AGESONHEAD91 AGESONHEAD90
ren AGESONHEAD92 AGESONHEAD91
ren AGESONHEAD93 AGESONHEAD92
ren AGESONHEAD94 AGESONHEAD93
ren AGESONHEAD95 AGESONHEAD94
ren AGESONHEAD96 AGESONHEAD95
ren AGESONHEAD97 AGESONHEAD96
ren AGESONHEAD99 AGESONHEAD98
ren AGESONHEAD101 AGESONHEAD100
ren AGESONHEAD103 AGESONHEAD102
ren AGESONHEAD105 AGESONHEAD104
ren AGESONHEAD107 AGESONHEAD106
ren AGESONHEAD109 AGESONHEAD108
ren AGESONHEAD111 AGESONHEAD110
ren AGESONHEAD113 AGESONHEAD112
ren AGESONHEAD115 AGESONHEAD114
ren AGESONHEAD117 AGESONHEAD116

ren AGESONWIFE68 AGESONWIFE67
ren AGESONWIFE69 AGESONWIFE68
ren AGESONWIFE70 AGESONWIFE69
ren AGESONWIFE71 AGESONWIFE70
ren AGESONWIFE72 AGESONWIFE71
ren AGESONWIFE73 AGESONWIFE72
ren AGESONWIFE74 AGESONWIFE73
ren AGESONWIFE75 AGESONWIFE74
ren AGESONWIFE76 AGESONWIFE75
ren AGESONWIFE77 AGESONWIFE76
ren AGESONWIFE78 AGESONWIFE77
ren AGESONWIFE79 AGESONWIFE78
ren AGESONWIFE80 AGESONWIFE79
ren AGESONWIFE81 AGESONWIFE80
ren AGESONWIFE82 AGESONWIFE81
ren AGESONWIFE83 AGESONWIFE82
ren AGESONWIFE84 AGESONWIFE83
ren AGESONWIFE85 AGESONWIFE84
ren AGESONWIFE86 AGESONWIFE85
ren AGESONWIFE87 AGESONWIFE86
ren AGESONWIFE88 AGESONWIFE87
ren AGESONWIFE89 AGESONWIFE88
ren AGESONWIFE90 AGESONWIFE89
ren AGESONWIFE91 AGESONWIFE90
ren AGESONWIFE92 AGESONWIFE91
ren AGESONWIFE93 AGESONWIFE92
ren AGESONWIFE94 AGESONWIFE93
ren AGESONWIFE95 AGESONWIFE94
ren AGESONWIFE96 AGESONWIFE95
ren AGESONWIFE97 AGESONWIFE96
ren AGESONWIFE99 AGESONWIFE98
ren AGESONWIFE101 AGESONWIFE100
ren AGESONWIFE103 AGESONWIFE102
ren AGESONWIFE105 AGESONWIFE104
ren AGESONWIFE107 AGESONWIFE106
ren AGESONWIFE109 AGESONWIFE108
ren AGESONWIFE111 AGESONWIFE110
ren AGESONWIFE113 AGESONWIFE112
ren AGESONWIFE115 AGESONWIFE114
ren AGESONWIFE117 AGESONWIFE116

* Replace values with missing if not valid 

replace FMONEYSON93 = . if FMONEYSON93 == 9999999
replace FMONEYSON94 = . if FMONEYSON94 == 9999999
replace FMONEYSON70 = . if FMONEYSON70 == 99999
replace FMONEYSON71 = . if FMONEYSON71 == 99999
replace FMONEYSON72 = . if FMONEYSON72 == 99999
replace FMONEYSON73 = . if FMONEYSON73 == 99999
replace FMONEYSON74 = . if FMONEYSON74 == 99999
replace FMONEYSON75 = . if FMONEYSON75 == 99999
replace FMONEYSON76 = . if FMONEYSON76 == 99999
replace FMONEYSON77 = . if FMONEYSON77 == 99999
replace FMONEYSON78 = . if FMONEYSON78 == 99999

* Create race variable

* For heads

gen FRACEHSON = RACEH68

replace FRACEHSON = 1 if RACEH68 == 1
replace FRACEHSON = . if ((RACEH68 == 0) | (RACEH68 == 9) | (RACEH68 == 8))
replace FRACEHSON = 0 if ((RACEH68 == 2) | (RACEH68 == 3) | (RACEH68 == 4) | (RACEH68 == 5) | (RACEH68 == 6) | (RACEH68 == 7))

replace FRACEHSON = 1 if RACEH69 == 1
replace FRACEHSON = . if ((RACEH69 == 0) | (RACEH69 == 9) | (RACEH69 == 8))
replace FRACEHSON = 0 if ((RACEH69 == 2) | (RACEH69 == 3) | (RACEH69 == 4) | (RACEH69 == 5) | (RACEH69 == 6) | (RACEH69 == 7))

replace FRACEHSON = 1 if RACEH70 == 1
replace FRACEHSON = . if ((RACEH70 == 0) | (RACEH70 == 9) | (RACEH70 == 8))
replace FRACEHSON = 0 if ((RACEH70 == 2) | (RACEH70 == 3) | (RACEH70 == 4) | (RACEH70 == 5) | (RACEH70 == 6) | (RACEH70 == 7))

replace FRACEHSON = 1 if RACEH71 == 1
replace FRACEHSON = . if ((RACEH71 == 0) | (RACEH71 == 9) | (RACEH71 == 8))
replace FRACEHSON = 0 if ((RACEH71 == 2) | (RACEH71 == 3) | (RACEH71 == 4) | (RACEH71 == 5) | (RACEH71 == 6) | (RACEH71 == 7))

replace FRACEHSON = 1 if RACEH72 == 1
replace FRACEHSON = . if ((RACEH72 == 0) | (RACEH72 == 9) | (RACEH72 == 8))
replace FRACEHSON = 0 if ((RACEH72 == 2) | (RACEH72 == 3) | (RACEH72 == 4) | (RACEH72 == 5) | (RACEH72 == 6) | (RACEH72 == 7))

replace FRACEHSON = 1 if RACEH73 == 1
replace FRACEHSON = . if ((RACEH73 == 0) | (RACEH73 == 9) | (RACEH73 == 8))
replace FRACEHSON = 0 if ((RACEH73 == 2) | (RACEH73 == 3) | (RACEH73 == 4) | (RACEH73 == 5) | (RACEH73 == 6) | (RACEH73 == 7))

replace FRACEHSON = 1 if RACEH74 == 1
replace FRACEHSON = . if ((RACEH74 == 0) | (RACEH74 == 9) | (RACEH74 == 8))
replace FRACEHSON = 0 if ((RACEH74 == 2) | (RACEH74 == 3) | (RACEH74 == 4) | (RACEH74 == 5) | (RACEH74 == 6) | (RACEH74 == 7))

replace FRACEHSON = 1 if RACEH75 == 1
replace FRACEHSON = . if ((RACEH75 == 0) | (RACEH75 == 9) | (RACEH75 == 8))
replace FRACEHSON = 0 if ((RACEH75 == 2) | (RACEH75 == 3) | (RACEH75 == 4) | (RACEH75 == 5) | (RACEH75 == 6) | (RACEH75 == 7))

replace FRACEHSON = 1 if RACEH76 == 1
replace FRACEHSON = . if ((RACEH76 == 0) | (RACEH76 == 9) | (RACEH76 == 8))
replace FRACEHSON = 0 if ((RACEH76 == 2) | (RACEH76 == 3) | (RACEH76 == 4) | (RACEH76 == 5) | (RACEH76 == 6) | (RACEH76 == 7))

replace FRACEHSON = 1 if RACEH77 == 1
replace FRACEHSON = . if ((RACEH77 == 0) | (RACEH77 == 9) | (RACEH77 == 8))
replace FRACEHSON = 0 if ((RACEH77 == 2) | (RACEH77 == 3) | (RACEH77 == 4) | (RACEH77 == 5) | (RACEH77 == 6) | (RACEH77 == 7))

replace FRACEHSON = 1 if RACEH78 == 1
replace FRACEHSON = . if ((RACEH78 == 0) | (RACEH78 == 9) | (RACEH78 == 8))
replace FRACEHSON = 0 if ((RACEH78 == 2) | (RACEH78 == 3) | (RACEH78 == 4) | (RACEH78 == 5) | (RACEH78 == 6) | (RACEH78 == 7))

replace FRACEHSON = 1 if RACEH79 == 1
replace FRACEHSON = . if ((RACEH79 == 0) | (RACEH79 == 9) | (RACEH79 == 8))
replace FRACEHSON = 0 if ((RACEH79 == 2) | (RACEH79 == 3) | (RACEH79 == 4) | (RACEH79 == 5) | (RACEH79 == 6) | (RACEH79 == 7))

replace FRACEHSON = 1 if RACEH80 == 1
replace FRACEHSON = . if ((RACEH80 == 0) | (RACEH80 == 9) | (RACEH80 == 8))
replace FRACEHSON = 0 if ((RACEH80 == 2) | (RACEH80 == 3) | (RACEH80 == 4) | (RACEH80 == 5) | (RACEH80 == 6) | (RACEH80 == 7))

replace FRACEHSON = 1 if RACEH81 == 1
replace FRACEHSON = . if ((RACEH81 == 0) | (RACEH81 == 9) | (RACEH81 == 8))
replace FRACEHSON = 0 if ((RACEH81 == 2) | (RACEH81 == 3) | (RACEH81 == 4) | (RACEH81 == 5) | (RACEH81 == 6) | (RACEH81 == 7))

replace FRACEHSON = 1 if RACEH82 == 1
replace FRACEHSON = . if ((RACEH82 == 0) | (RACEH82 == 9) | (RACEH82 == 8))
replace FRACEHSON = 0 if ((RACEH82 == 2) | (RACEH82 == 3) | (RACEH82 == 4) | (RACEH82 == 5) | (RACEH82 == 6) | (RACEH82 == 7))

replace FRACEHSON = 1 if RACEH83 == 1
replace FRACEHSON = . if ((RACEH83 == 0) | (RACEH83 == 9) | (RACEH83 == 8))
replace FRACEHSON = 0 if ((RACEH83 == 2) | (RACEH83 == 3) | (RACEH83 == 4) | (RACEH83 == 5) | (RACEH83 == 6) | (RACEH83 == 7))

replace FRACEHSON = 1 if RACEH84 == 1
replace FRACEHSON = . if ((RACEH84 == 0) | (RACEH84 == 9) | (RACEH84 == 8))
replace FRACEHSON = 0 if ((RACEH84 == 2) | (RACEH84 == 3) | (RACEH84 == 4) | (RACEH84 == 5) | (RACEH84 == 6) | (RACEH84 == 7))

replace FRACEHSON = 1 if RACEH85 == 1
replace FRACEHSON = . if ((RACEH85 == 0) | (RACEH85 == 9) | (RACEH85 == 8))
replace FRACEHSON = 0 if ((RACEH85 == 2) | (RACEH85 == 3) | (RACEH85 == 4) | (RACEH85 == 5) | (RACEH85 == 6) | (RACEH85 == 7))

replace FRACEHSON = 1 if RACEH86 == 1
replace FRACEHSON = . if ((RACEH86 == 0) | (RACEH86 == 9) | (RACEH86 == 8))
replace FRACEHSON = 0 if ((RACEH86 == 2) | (RACEH86 == 3) | (RACEH86 == 4) | (RACEH86 == 5) | (RACEH86 == 6) | (RACEH86 == 7))

replace FRACEHSON = 1 if RACEH87 == 1
replace FRACEHSON = . if ((RACEH87 == 0) | (RACEH87 == 9) | (RACEH87 == 8))
replace FRACEHSON = 0 if ((RACEH87 == 2) | (RACEH87 == 3) | (RACEH87 == 4) | (RACEH87 == 5) | (RACEH87 == 6) | (RACEH87 == 7))

replace FRACEHSON = 1 if RACEH88 == 1
replace FRACEHSON = . if ((RACEH88 == 0) | (RACEH88 == 9) | (RACEH88 == 8))
replace FRACEHSON = 0 if ((RACEH88 == 2) | (RACEH88 == 3) | (RACEH88 == 4) | (RACEH88 == 5) | (RACEH88 == 6) | (RACEH88 == 7))

replace FRACEHSON = 1 if RACEH89 == 1
replace FRACEHSON = . if ((RACEH89 == 0) | (RACEH89 == 9) | (RACEH89 == 8))
replace FRACEHSON = 0 if ((RACEH89 == 2) | (RACEH89 == 3) | (RACEH89 == 4) | (RACEH89 == 5) | (RACEH89 == 6) | (RACEH89 == 7))

replace FRACEHSON = 1 if RACEH90 == 1
replace FRACEHSON = . if ((RACEH90 == 0) | (RACEH90 == 9) | (RACEH90 == 8))
replace FRACEHSON = 0 if ((RACEH90 == 2) | (RACEH90 == 3) | (RACEH90 == 4) | (RACEH90 == 5) | (RACEH90 == 6) | (RACEH90 == 7))

replace FRACEHSON = 1 if RACEH91 == 1
replace FRACEHSON = . if ((RACEH91 == 0) | (RACEH91 == 9) | (RACEH91 == 8))
replace FRACEHSON = 0 if ((RACEH91 == 2) | (RACEH91 == 3) | (RACEH91 == 4) | (RACEH91 == 5) | (RACEH91 == 6) | (RACEH91 == 7))

replace FRACEHSON = 1 if RACEH92 == 1
replace FRACEHSON = . if ((RACEH92 == 0) | (RACEH92 == 9) | (RACEH92 == 8))
replace FRACEHSON = 0 if ((RACEH92 == 2) | (RACEH92 == 3) | (RACEH92 == 4) | (RACEH92 == 5) | (RACEH92 == 6) | (RACEH92 == 7))

replace FRACEHSON = 1 if RACEH93 == 1
replace FRACEHSON = . if ((RACEH93 == 0) | (RACEH93 == 9) | (RACEH93 == 8))
replace FRACEHSON = 0 if ((RACEH93 == 2) | (RACEH93 == 3) | (RACEH93 == 4) | (RACEH93 == 5) | (RACEH93 == 6) | (RACEH93 == 7))

replace FRACEHSON = 1 if RACEH94 == 1
replace FRACEHSON = . if ((RACEH94 == 0) | (RACEH94 == 9) | (RACEH94 == 8))
replace FRACEHSON = 0 if ((RACEH94 == 2) | (RACEH94 == 3) | (RACEH94 == 4) | (RACEH94 == 5) | (RACEH94 == 6) | (RACEH94 == 7))

replace FRACEHSON = 1 if RACEH95 == 1
replace FRACEHSON = . if ((RACEH95 == 0) | (RACEH95 == 9) | (RACEH95 == 8))
replace FRACEHSON = 0 if ((RACEH95 == 2) | (RACEH95 == 3) | (RACEH95 == 4) | (RACEH95 == 5) | (RACEH95 == 6) | (RACEH95 == 7))

replace FRACEHSON = 1 if RACEH96 == 1
replace FRACEHSON = . if ((RACEH96 == 0) | (RACEH96 == 9) | (RACEH96 == 8))
replace FRACEHSON = 0 if ((RACEH96 == 2) | (RACEH96 == 3) | (RACEH96 == 4) | (RACEH96 == 5) | (RACEH96 == 6) | (RACEH96 == 7))

replace FRACEHSON = 1 if RACEH98 == 1
replace FRACEHSON = . if ((RACEH98 == 0) | (RACEH98 == 9) | (RACEH98 == 8))
replace FRACEHSON = 0 if ((RACEH98 == 2) | (RACEH98 == 3) | (RACEH98 == 4) | (RACEH98 == 5) | (RACEH98 == 6) | (RACEH98 == 7))

replace FRACEHSON = 1 if RACEH100 == 1
replace FRACEHSON = . if ((RACEH100 == 0) | (RACEH100 == 9) | (RACEH100 == 8))
replace FRACEHSON = 0 if ((RACEH100 == 2) | (RACEH100 == 3) | (RACEH100 == 4) | (RACEH100 == 5) | (RACEH100 == 6) | (RACEH100 == 7))

replace FRACEHSON = 1 if RACEH102 == 1
replace FRACEHSON = . if ((RACEH102 == 0) | (RACEH102 == 9) | (RACEH102 == 8))
replace FRACEHSON = 0 if ((RACEH102 == 2) | (RACEH102 == 3) | (RACEH102 == 4) | (RACEH102 == 5) | (RACEH102 == 6) | (RACEH102 == 7))

replace FRACEHSON = 1 if RACEH104 == 1
replace FRACEHSON = . if ((RACEH104 == 0) | (RACEH104 == 9) | (RACEH104 == 8))
replace FRACEHSON = 0 if ((RACEH104 == 2) | (RACEH104 == 3) | (RACEH104 == 4) | (RACEH104 == 5) | (RACEH104 == 6) | (RACEH104 == 7))

replace FRACEHSON = 1 if RACEH106 == 1
replace FRACEHSON = . if ((RACEH106 == 0) | (RACEH106 == 9) | (RACEH106 == 8))
replace FRACEHSON = 0 if ((RACEH106 == 2) | (RACEH106 == 3) | (RACEH106 == 4) | (RACEH106 == 5) | (RACEH106 == 6) | (RACEH106 == 7))

replace FRACEHSON = 1 if RACEH108 == 1
replace FRACEHSON = . if ((RACEH108 == 0) | (RACEH108 == 9) | (RACEH108 == 8))
replace FRACEHSON = 0 if ((RACEH108 == 2) | (RACEH108 == 3) | (RACEH108 == 4) | (RACEH108 == 5) | (RACEH108 == 6) | (RACEH108 == 7))

replace FRACEHSON = 1 if RACEH110 == 1
replace FRACEHSON = . if ((RACEH110 == 0) | (RACEH110 == 9) | (RACEH110 == 8))
replace FRACEHSON = 0 if ((RACEH110 == 2) | (RACEH110 == 3) | (RACEH110 == 4) | (RACEH110 == 5) | (RACEH110 == 6) | (RACEH110 == 7))

replace FRACEHSON = 1 if RACEH112 == 1
replace FRACEHSON = . if ((RACEH112 == 0) | (RACEH112 == 9) | (RACEH112 == 8))
replace FRACEHSON = 0 if ((RACEH112 == 2) | (RACEH112 == 3) | (RACEH112 == 4) | (RACEH112 == 5) | (RACEH112 == 6) | (RACEH112 == 7))

replace FRACEHSON = 1 if RACEH114 == 1
replace FRACEHSON = . if ((RACEH114 == 0) | (RACEH114 == 9) | (RACEH114 == 8))
replace FRACEHSON = 0 if ((RACEH114 == 2) | (RACEH114 == 3) | (RACEH114 == 4) | (RACEH114 == 5) | (RACEH114 == 6) | (RACEH114 == 7))

replace FRACEHSON = 1 if RACEH116 == 1
replace FRACEHSON = . if ((RACEH116 == 0) | (RACEH116 == 9) | (RACEH116 == 8))
replace FRACEHSON = 0 if ((RACEH116 == 2) | (RACEH116 == 3) | (RACEH116 == 4) | (RACEH116 == 5) | (RACEH116 == 6) | (RACEH116 == 7))

* For "wives"

gen FRACEWSON = RACEW85

replace FRACEWSON = 1 if RACEW85 == 1
replace FRACEWSON = . if ((RACEW85 == 0) | (RACEW85 == 9) | (RACEW85 == 8))
replace FRACEWSON = 0 if ((RACEW85 == 2) | (RACEW85 == 3) | (RACEW85 == 4) | (RACEW85 == 5) | (RACEW85 == 6) | (RACEW85 == 7))

replace FRACEWSON = 1 if RACEW86 == 1
replace FRACEWSON = . if ((RACEW86 == 0) | (RACEW86 == 9) | (RACEW86 == 8))
replace FRACEWSON = 0 if ((RACEW86 == 2) | (RACEW86 == 3) | (RACEW86 == 4) | (RACEW86 == 5) | (RACEW86 == 6) | (RACEW86 == 7))

replace FRACEWSON = 1 if RACEW87 == 1
replace FRACEWSON = . if ((RACEW87 == 0) | (RACEW87 == 9) | (RACEW87 == 8))
replace FRACEWSON = 0 if ((RACEW87 == 2) | (RACEW87 == 3) | (RACEW87 == 4) | (RACEW87 == 5) | (RACEW87 == 6) | (RACEW87 == 7))

replace FRACEWSON = 1 if RACEW88 == 1
replace FRACEWSON = . if ((RACEW88 == 0) | (RACEW88 == 9) | (RACEW88 == 8))
replace FRACEWSON = 0 if ((RACEW88 == 2) | (RACEW88 == 3) | (RACEW88 == 4) | (RACEW88 == 5) | (RACEW88 == 6) | (RACEW88 == 7))

replace FRACEWSON = 1 if RACEW89 == 1
replace FRACEWSON = . if ((RACEW89 == 0) | (RACEW89 == 9) | (RACEW89 == 8))
replace FRACEWSON = 0 if ((RACEW89 == 2) | (RACEW89 == 3) | (RACEW89 == 4) | (RACEW89 == 5) | (RACEW89 == 6) | (RACEW89 == 7))

replace FRACEWSON = 1 if RACEW90 == 1
replace FRACEWSON = . if ((RACEW90 == 0) | (RACEW90 == 9) | (RACEW90 == 8))
replace FRACEWSON = 0 if ((RACEW90 == 2) | (RACEW90 == 3) | (RACEW90 == 4) | (RACEW90 == 5) | (RACEW90 == 6) | (RACEW90 == 7))

replace FRACEWSON = 1 if RACEW91 == 1
replace FRACEWSON = . if ((RACEW91 == 0) | (RACEW91 == 9) | (RACEW91 == 8))
replace FRACEWSON = 0 if ((RACEW91 == 2) | (RACEW91 == 3) | (RACEW91 == 4) | (RACEW91 == 5) | (RACEW91 == 6) | (RACEW91 == 7))

replace FRACEWSON = 1 if RACEW92 == 1
replace FRACEWSON = . if ((RACEW92 == 0) | (RACEW92 == 9) | (RACEW92 == 8))
replace FRACEWSON = 0 if ((RACEW92 == 2) | (RACEW92 == 3) | (RACEW92 == 4) | (RACEW92 == 5) | (RACEW92 == 6) | (RACEW92 == 7))

replace FRACEWSON = 1 if RACEW93 == 1
replace FRACEWSON = . if ((RACEW93 == 0) | (RACEW93 == 9) | (RACEW93 == 8))
replace FRACEWSON = 0 if ((RACEW93 == 2) | (RACEW93 == 3) | (RACEW93 == 4) | (RACEW93 == 5) | (RACEW93 == 6) | (RACEW93 == 7))

replace FRACEWSON = 1 if RACEW94 == 1
replace FRACEWSON = . if ((RACEW94 == 0) | (RACEW94 == 9) | (RACEW94 == 8))
replace FRACEWSON = 0 if ((RACEW94 == 2) | (RACEW94 == 3) | (RACEW94 == 4) | (RACEW94 == 5) | (RACEW94 == 6) | (RACEW94 == 7))

replace FRACEWSON = 1 if RACEW95 == 1
replace FRACEWSON = . if ((RACEW95 == 0) | (RACEW95 == 9) | (RACEW95 == 8))
replace FRACEWSON = 0 if ((RACEW95 == 2) | (RACEW95 == 3) | (RACEW95 == 4) | (RACEW95 == 5) | (RACEW95 == 6) | (RACEW95 == 7))

replace FRACEWSON = 1 if RACEW96 == 1
replace FRACEWSON = . if ((RACEW96 == 0) | (RACEW96 == 9) | (RACEW96 == 8))
replace FRACEWSON = 0 if ((RACEW96 == 2) | (RACEW96 == 3) | (RACEW96 == 4) | (RACEW96 == 5) | (RACEW96 == 6) | (RACEW96 == 7))

replace FRACEWSON = 1 if RACEW98 == 1
replace FRACEWSON = . if ((RACEW98 == 0) | (RACEW98 == 9) | (RACEW98 == 8))
replace FRACEWSON = 0 if ((RACEW98 == 2) | (RACEW98 == 3) | (RACEW98 == 4) | (RACEW98 == 5) | (RACEW98 == 6) | (RACEW98 == 7))

replace FRACEWSON = 1 if RACEW100 == 1
replace FRACEWSON = . if ((RACEW100 == 0) | (RACEW100 == 9) | (RACEW100 == 8))
replace FRACEWSON = 0 if ((RACEW100 == 2) | (RACEW100 == 3) | (RACEW100 == 4) | (RACEW100 == 5) | (RACEW100 == 6) | (RACEW100 == 7))

replace FRACEWSON = 1 if RACEW102 == 1
replace FRACEWSON = . if ((RACEW102 == 0) | (RACEW102 == 9) | (RACEW102 == 8))
replace FRACEWSON = 0 if ((RACEW102 == 2) | (RACEW102 == 3) | (RACEW102 == 4) | (RACEW102 == 5) | (RACEW102 == 6) | (RACEW102 == 7))

replace FRACEWSON = 1 if RACEW104 == 1
replace FRACEWSON = . if ((RACEW104 == 0) | (RACEW104 == 9) | (RACEW104 == 8))
replace FRACEWSON = 0 if ((RACEW104 == 2) | (RACEW104 == 3) | (RACEW104 == 4) | (RACEW104 == 5) | (RACEW104 == 6) | (RACEW104 == 7))

replace FRACEWSON = 1 if RACEW106 == 1
replace FRACEWSON = . if ((RACEW106 == 0) | (RACEW106 == 9) | (RACEW106 == 8))
replace FRACEWSON = 0 if ((RACEW106 == 2) | (RACEW106 == 3) | (RACEW106 == 4) | (RACEW106 == 5) | (RACEW106 == 6) | (RACEW106 == 7))

replace FRACEWSON = 1 if RACEW108 == 1
replace FRACEWSON = . if ((RACEW108 == 0) | (RACEW108 == 9) | (RACEW108 == 8))
replace FRACEWSON = 0 if ((RACEW108 == 2) | (RACEW108 == 3) | (RACEW108 == 4) | (RACEW108 == 5) | (RACEW108 == 6) | (RACEW108 == 7))

replace FRACEWSON = 1 if RACEW110 == 1
replace FRACEWSON = . if ((RACEW110 == 0) | (RACEW110 == 9) | (RACEW110 == 8))
replace FRACEWSON = 0 if ((RACEW110 == 2) | (RACEW110 == 3) | (RACEW110 == 4) | (RACEW110 == 5) | (RACEW110 == 6) | (RACEW110 == 7))

replace FRACEWSON = 1 if RACEW112 == 1
replace FRACEWSON = . if ((RACEW112 == 0) | (RACEW112 == 9) | (RACEW112 == 8))
replace FRACEWSON = 0 if ((RACEW112 == 2) | (RACEW112 == 3) | (RACEW112 == 4) | (RACEW112 == 5) | (RACEW112 == 6) | (RACEW112 == 7))

replace FRACEWSON = 1 if RACEW114 == 1
replace FRACEWSON = . if ((RACEW114 == 0) | (RACEW114 == 9) | (RACEW114 == 8))
replace FRACEWSON = 0 if ((RACEW114 == 2) | (RACEW114 == 3) | (RACEW114 == 4) | (RACEW114 == 5) | (RACEW114 == 6) | (RACEW114 == 7))

replace FRACEWSON = 1 if RACEW116 == 1
replace FRACEWSON = . if ((RACEW116 == 0) | (RACEW116 == 9) | (RACEW116 == 8))
replace FRACEWSON = 0 if ((RACEW116 == 2) | (RACEW116 == 3) | (RACEW116 == 4) | (RACEW116 == 5) | (RACEW116 == 6) | (RACEW116 == 7))

drop RACEW* 

* Save wide data
gen _ER30001=intnr67
drop ER*
rename _ER30001 ER30001
cd "${path}"
save "${path}/Data/sons_data", replace
